<?php

namespace app\common\model;

class MallCollect extends Base
{

    protected $deleteTime = false;


    /**
     * 根据用户唯一识别号和商品id查询是否收藏 存在则收藏
     * @param string $openid
     * @param int $goods_id
     * @return array|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getMallCollectByOpenidAndGoodsInfo(string $openid = '', int $goods_id = 0)
    {
        return $this->where('openid', $openid)
            ->where('goods_id', $goods_id)
            ->find();
    }
    public function goods(){
        return $this->hasOne(MallGoods::class,'id','goods_id');
    }

}